﻿<%@ Page Language="C#"  MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="Nivdal.ThreadDetails"
 Title=" " StylesheetTheme="SkinFile" Codebehind="ThreadDetails.aspx.cs" MaintainScrollPositionOnPostback="true" %>

<asp:Content ID="PageNameContent" ContentPlaceHolderID="PageNamePlaceHolder" runat="server">
    <asp:HyperLink ID="PageNameForumHyperLink" runat="server" CssClass="PageNameContentStyle"></asp:HyperLink>
    <asp:Label ID="PageNameLabel" runat="server" CssClass="PageNameContentStyle"></asp:Label>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:HiddenField ID="ThreadIdHiddenField" runat="server" />
    <asp:HiddenField ID="ForumIdHiddenField" runat="server" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <div class="basic_element">
        <asp:Label ID="MessageLabel" runat="server" Text="" SkinID="GreenSmallHeaderLabel"></asp:Label>
        <a name="top"></a>
        <asp:SqlDataSource ID="ThreadDetailsSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="Nivdal_ForumGetThreadDetails" SelectCommandType="StoredProcedure"
            UpdateCommand="Nivdal_UpdatethreadDetails" UpdateCommandType="StoredProcedure">
            <UpdateParameters>
                <asp:ControlParameter ControlID="ThreadIdHiddenField" PropertyName="Value" Name="ThreadId" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:FormView ID="ThreadTitleFormView" runat="server" DataSourceID="ThreadDetailsSqlDataSource" Width="100%">
            <ItemTemplate>
                <div class="red_title">
                   <asp:Label ID="ThreadNameLabel" runat="server" Text='<%# Eval("ThreadName") %>' CssClass="white_title"></asp:Label>
                </div>
                <div class="padding5">

                    <asp:HyperLink ID="ForumHyperlink" runat="server" Text='<%# "(" + Eval("ForumName") + ")" %>' SkinID="GreenTitleHyperLink"
                     NavigateUrl='<%# "~/ForumDetails.aspx?Id=" + Eval("ForumId") %>'></asp:HyperLink>
                     <br />
                    <asp:Label ID="TotalPostsTitleLabel" runat="server" Text="<%$ Resources:Resource, ThreadDetails_TotalPostsTitleLabel %>" SkinID="InfoLabel" ></asp:Label>
                    <asp:Label ID="TotalPostsLabel" runat="server" Text='<%# Eval("NumberOfPosts") %>' SkinID="GridLabel"></asp:Label>            
                    <asp:Panel ID="IsClosedPanel" runat="server" Visible='<%# Eval("IsClosed") %>' >
                        <asp:Label ID="IsClosedLabel" runat="server" Text="<%$ Resources:Resource, ThreadDetails_IsClosedLabel%>" SkinID="InfoLabel"></asp:Label>
                    </asp:Panel>   
                    <br />
                    <asp:LinkButton ID="EditLinkButton" runat="server" SkinID="GreenTitleLink" Text="<%$ Resources:Resource, Global_Edit %>"
                     CommandName="Edit" Visible='<%# IsModerator() %>'></asp:LinkButton>
                 
                </div>                       
            </ItemTemplate>
            <EditItemTemplate>
                <div class="red_title">
                <asp:Label ID="ThreadNameTitleLabel" runat="server" Text="<%$ Resources:Resource, ForumConversations_ThreadNameLabel %>"
                 SkinID="InfoLabel"></asp:Label>
                </div>
                <div class="padding5">
                    <asp:TextBox ID="ThreadNameTextBox" runat="server" Text='<%# Bind("ThreadName") %>' TextMode="SingleLine"
                     Width="300"></asp:TextBox>
                     <br />
                    <asp:CheckBox ID="StickyCheckBox" runat="server" Text="<%$ Resources:Resource, Forum_PinnedThread %> " CssClass="NewsItemStyle"
                     Checked='<%# Bind("IsSticky") %>'/>
                    <asp:CheckBox ID="ClosedCheckBox" runat="server" Text="<%$ Resources:Resource, Forum_closedThread %> " CssClass="NewsItemStyle"
                     Checked='<%# Bind("IsClosed") %>'/> 
                     <br /><br />                
                    <asp:LinkButton ID="UpdateLinkButton" runat="server" SkinID="GreenTitleLink" CommandName="Update"
                    Text="<%$ Resources:Resource, Global_Update %>"></asp:LinkButton>
                    &nbsp;&nbsp;
                    <asp:LinkButton ID="CancelLinkButton" runat="server" SkinID="GreenTitleLink" CommandName="Cancel"
                    Text="<%$ Resources:Resource, Global_Cancel %>"></asp:LinkButton>
                </div>
            </EditItemTemplate>
        </asp:FormView>
        
        
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
            <ProgressTemplate>
                <div class="ajaxloader">
                    <asp:Image ID="AjaxProgressImage" runat="server" ImageUrl="~/Images/ajax-loader.gif" />
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        
        <div class="padding5">
        
        <table style="width: 100%;">
            <tr>
                <td style="text-align:left; padding-left:10px;width:25%">
                    <asp:HyperLink ID="UpperFirstHyperLink" runat="server" SkinID="BlackHyperLinkSkin" Text="<%$ Resources:Resource, Global_First %>"  ToolTip="<%$ Resources:Resource, Global_First %>" ></asp:HyperLink>
                    &nbsp;&nbsp;
                    <asp:HyperLink ID="UpperPreviousHyperLink" runat="server" SkinID="BlackHyperLinkSkin" Text="<%$ Resources:Resource, Global_Previous %>" ToolTip="<%$ Resources:Resource, Global_Previous %>" ></asp:HyperLink>
                </td>            
                <td style="text-align:right; width:25%;">
                    <asp:HyperLink ID="UpperNextHyperLink" runat="server" SkinID="BlackHyperLinkSkin" Text="<%$ Resources:Resource, Global_Next %>"  ToolTip="<%$ Resources:Resource, Global_Next %>" ></asp:HyperLink>
                    &nbsp;&nbsp;
                    <asp:HyperLink ID="UpperLastHyperLink" runat="server" SkinID="BlackHyperLinkSkin" Text="<%$ Resources:Resource, ThreadDetails_Last %>"  ToolTip="<%$ Resources:Resource, ThreadDetails_Last %>" ></asp:HyperLink>
                </td>
                <td style="width:50%; text-align:center;">
                    <asp:Button ID="NewMessageButton" runat="server" Text="<%$ Resources:Resource, ThreadDetails_NewMessageButton %>" 
                        CssClass="ForumButtonWithIconStyle" onclick="NewMessageButtonClick" />
                </td>
                    
            </tr>
        </table>
        <br /> 
        <asp:ListView ID="GetThreadPostsListView" runat="server" DataKeyNames="PostId" OnItemCommand="GetThreadPostsListView_OnItemCommand"
                    DataSourceID="GetThreadPostsSqlDataSource">
            <LayoutTemplate>
                <asp:Label ID="itemPlaceholder" runat="server"></asp:Label>
            </LayoutTemplate>
            <ItemTemplate>
                <table style="border-width:1px; border-color:#A0A0A0; width:100%; border-style:solid; border-collapse:collapse;" cellpadding="0" cellspacing="0">
                    <tr>
                    <td style="background-color:#C0C0C0; padding:5px; border-bottom-style:solid; border-bottom-color:#A0A0A0; border-bottom-width:1px;">
                        <asp:Panel ID="DirectionLTRPanel" runat="server" Direction="LeftToRight">
                        <div style="float:left; padding: 0 5px 0 5px;" >
                            <asp:Image ID="UseerPic" runat="server" ImageUrl='<%# Eval("UserPicture") %>' Height="32" AlternateText="user pic"
                             onerror="this.src='Images/menupicture.gif';" CssClass="rounded_corners"/>
                         </div>

                        <div style="float:left;">
                            <asp:Image ID="UserIconImage" runat="server" ImageUrl='<%# Eval("UserIcon", "~/Images/Icons/{0}") %>' 
                                ToolTip='<%# Eval("UserIconText") %>'  />
                            <asp:HyperLink ID="PostedByNameHyperLink" runat="server" Text='<%# Eval("PostedByName") %>'
                            NavigateUrl='<%# Eval("PostedById", "UserPage.aspx?Id={0}") %>' SkinID="GreenTitleHyperLink"></asp:HyperLink>
                            <asp:Image ID="IsPremiumImage" runat="server" ToolTip="<%$ Resources:Resource, Global_PremiumUser %>" ImageUrl="~/Images/Icons/premium.png"
                             Visible='<%# Eval("IsPremium") %>' />
                            <asp:ImageButton ID="countryImageButton" runat="server" ImageUrl='<%# Eval("Flag", "~/Images/Flags/{0}") %>'  
                             PostBackUrl='<%# Eval("CountryId", "Country.aspx?Id={0}") %>' ToolTip='<%# Eval("CountryName") %>'/>
                            <asp:Image ID="OnlineImage" runat="server" ToolTip="<%$ Resources:Resource, Global_Online %>" ImageUrl="~/Images/Icons/IsOnline.png"
                             Visible='<%# Eval("IsOnline") %>' />
                            <asp:Image ID="Image2" runat="server" ToolTip="<%$ Resources:Resource, Global_Offline %>" ImageUrl="~/Images/Icons/offline.png"
                             Visible='<%# !((bool)Eval("IsOnline")) %>' /> 
                             <br />
                            <asp:Image ID="NumberOfPostsImage" runat="server" ImageUrl='<%# NumPostImage(Eval("NumPosts")) %>' 
                            ToolTip='<%# Eval("NumPosts", "{0} posts") %>' />
                        </div>
                        <div style="float:right;">
                            <table>
                                <tr>
                                    <td style="padding-right:10px; padding-left:10px;">
                                        <asp:Panel ID="PanelNormal" runat="server" Direction='<%# CorrectDirection() %>' >
                                            <asp:Label ID="TeamNameTitleLabel" runat="server" Text='<%# Resources.Resource.Global_Team+ ":"%>' SkinID="InfoLabel"></asp:Label>
                                            <asp:HyperLink ID="TeamNameHyperLink" runat="server" Text='<%# Eval("TeamName") %>'
                                            NavigateUrl='<%# Eval("TeamId", "TeamHomePage.aspx?TeamId={0}") %>' SkinID="GreenTitleHyperLink"></asp:HyperLink>
                                            <br />
                                            <asp:Label ID="LeagueNameTitleLabel" runat="server" Text="<%$ Resources:Resource, ThreadDetails_LeagueNameTitleLabel %>" SkinID="InfoLabel"></asp:Label>
                                            <asp:HyperLink ID="LeagueNameHyperLink" runat="server" Text='<%# Eval("LeagueName") %>'
                                            NavigateUrl='<%# Eval("LeagueId", "League.aspx?LeagueId={0}") %>' SkinID="GreenTitleHyperLink"></asp:HyperLink>
                                        </asp:Panel>
                                    </td>
                                    <td style="text-align:center; vertical-align:middle;">
                                    <div>
                                        <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Logo") %>' onerror="this.src='Images/menupicture.gif';"
                                        Width="32px" Height="32px" CssClass="rounded_corners" />
                                    </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        </asp:Panel>
                    </td></tr>
                    <tr><td style="background-color:#F4F3F3; padding-left:10px; padding-right:10px;">
                        <asp:Label ID="NumberTitleLabel" runat="server" Text="#" SkinID="InfoLabel"></asp:Label>
                        <asp:HyperLink ID="NumberInThreadHyperLink" runat="server" Text='<%# Eval("NumberInThread") %>'
                            NavigateUrl='<%# Eval("ThreadId", "ThreadDetails.aspx?ThreadId={0}&PostId="+Eval("PostId")) %>' SkinID="InfoHyperLink"></asp:HyperLink>
                        &nbsp;&nbsp;
                        <asp:Label ID="PostDateLabel" runat="server" Text='<%# Eval("PostDate")%>' SkinID="InfoLabel"> </asp:Label>  
                        &nbsp;&nbsp;
                        <asp:Label ID="AsReplyToPostNumberTitleLabel" runat="server" Text="<%$ Resources:Resource, ThreadDetails_AsReplyToPostNumberTitleLabel %>" SkinID="InfoLabel" Visible='<%# Eval("IsReplyTosomething") %>'></asp:Label>
                        <asp:HyperLink ID="AsReplyToPostNumberHyperLink" runat="server" Text='<%# Eval("AsReplyToPostNumber") %>' Visible='<%# Eval("IsReplyTosomething") %>'
                            NavigateUrl='<%# Eval("ThreadId", "ThreadDetails.aspx?ThreadId={0}&PostId="+Eval("AsReplyToPostId")) %>' SkinID="InfoHyperLink"></asp:HyperLink>
                        <asp:Label ID="IsReplyToByTitleLabel" runat="server" Text="<%$ Resources:Resource, ThreadDetails_IsReplyToByTitleLabel %>" SkinID="InfoLabel" Visible='<%# Eval("IsReplyTosomething") %>'></asp:Label>
                        <asp:HyperLink ID="IsReplyToUserNameHyperLink" runat="server" Visible='<%# Eval("IsReplyTosomething") %>' SkinID="InfoHyperLink"
                            NavigateUrl='<%# Eval("AsReplyToUserId", "UserPage.aspx?Id={0}") %>' Text='<%# Eval("AsReplyToUserName") %>'></asp:HyperLink>
                            
                    </td></tr>
                    <tr><td style="padding:10px; background-color:White; border-color:#A0A0A0; border-top-style:solid; border-top-width:1px;">
                         <div style="width:570px; overflow:auto;">
                            <asp:Label ID="PostTextLabel" runat="server" Text='<%# Eval("PostText") %>'  SkinID="GridLabel"></asp:Label>
                         </div>
                    </td></tr>
                    <asp:Panel ID="SignaturePanel" runat="server" Visible='<%# Eval("Signature").ToString().Length > 0 %>'>
                    <tr>
                    <td style="padding:10px;border-top:1px dashed #A0A0A0;">
                        <asp:Label ID="SignatureLabel" runat="server" Text='<%# ReplaceEOL((string)Eval("Signature")) %>' SkinID="GridLabel"></asp:Label>
                    </td>
                    </tr>
                    </asp:Panel>
                    <tr><td style="padding:10px;border-top:1px dashed #A0A0A0;">
                        <div style="float:left;">
                            <asp:ImageButton ID="ReplyImageButton" runat="server" ImageUrl="~/Images/Icons/replay.png" ToolTip="<%$ Resources:Resource, ThreadDetails_ReplyImageToolTip %>" Visible='<%# Eval("CanReply") %>'
                             PostBackUrl='<%# Eval("ThreadId", "WriteForumPost.aspx?ThreadId={0}&ReplyToUser="+Eval("PostedById")+"&ReplyToPost="+Eval("PostId")) %>'/>
                            <asp:ImageButton ID="ReportImageButton" runat="server" 
                             message="<%$ Resources:Resource, ThreadDetails_ReportImageButtonOnClientClick %>"
                             OnClientClick="return confirm(this.getAttribute('message'))"
                             ImageUrl="~/Images/Icons/report.png" ToolTip="<%$ Resources:Resource, ThreadDetails_ReportImageButtonToolTip %>" 
                             CommandName="Report" CommandArgument='<%# Eval("PostId") %>' Visible='<%# IsUserAuthenticated() %>'
                             PostBackUrl='<%# Eval("PostId", "ReportForumBehaviour.aspx?PostId={0}&ReportedUserId="+Eval("PostedById")) %>'/>
                            <asp:ImageButton ID="DeleteImageButton" runat="server" Visible='<%# Eval("CanDelete") %>' 
                            message="<%$ Resources:Resource, ThreadDetails_DeleteImageButtonOnClientClick %>"
                            OnClientClick="return confirm(this.getAttribute('message'))"
                            CommandName="DeleteThread" ImageUrl="~/Images/Icons/delete.png" ToolTip="<%$ Resources:Resource, Global_Delete %>"/>
                            <asp:ImageButton ID="EditImageButton" runat="server"  Visible='<%# (bool)Eval("CanEdit") && (!(bool)Eval("IsOld")) %>' 
                            CommandName="EditThread" ToolTip="<%$ Resources:Resource, Global_Edit %>" ImageUrl="~/Images/Icons/edit.png"/>
                        </div>
                        
                        <div style="float:right;">
                            <asp:Label ID="EditedDateTitleLabel" runat="server" Text="<%$ Resources:Resource, ThreadDetails_EditedDateTitleLabel %>" SkinID="GreyInfoLabel"
                             Visible='<%# Eval("EditedDate").ToString() != Eval("PostDate").ToString()  %>'></asp:Label>
                            <asp:Label ID="EditedDateLabel" runat="server" Text='<%# Eval("EditedDate")%>' SkinID="GreyInfoLabel"
                             Visible='<%# Eval("EditedDate").ToString() != Eval("PostDate").ToString()  %>'> </asp:Label>
                        </div>
                    </td></tr>
                
                </table>
                
               
            </ItemTemplate>
            <ItemSeparatorTemplate>
                <br />
            </ItemSeparatorTemplate>
        </asp:ListView>
       <asp:SqlDataSource ID="GetThreadPostsSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="Nivdal_ForumGetThreadPosts" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
        <br />
        <table style="width: 40%;">
            <tr>
                <td style="text-align:left; padding-left:10px;">
                    <asp:HyperLink ID="LowerFirstHyperLink" runat="server" SkinID="BlackHyperLinkSkin" Text="<%$ Resources:Resource, Global_First %>" ToolTip="<%$ Resources:Resource, Global_First%>"></asp:HyperLink>
                    &nbsp;&nbsp;
                    <asp:HyperLink ID="LowerPreviousHyperLink" runat="server" SkinID="BlackHyperLinkSkin" Text="<%$ Resources:Resource, Global_Previous %>"  ToolTip="<%$ Resources:Resource, Global_Previous %>" ></asp:HyperLink>
                </td>
                <td style="text-align:right; padding-right:30px;">
                    <asp:HyperLink ID="LowerNextHyperLink" runat="server" SkinID="BlackHyperLinkSkin" Text="<%$ Resources:Resource, Global_Next %>" ToolTip="<%$ Resources:Resource, Global_Next %>"></asp:HyperLink>
                     &nbsp;&nbsp;
                    <asp:HyperLink ID="LowerLastHyperLink" runat="server" SkinID="BlackHyperLinkSkin" Text="<%$ Resources:Resource, ThreadDetails_Last %>" ToolTip="<%$ Resources:Resource, ThreadDetails_Last %>"></asp:HyperLink>
                </td>
            </tr>
        </table>
        <br />
        <a href="#top" style="font-family:Arial;font-size:12px;color:#658321; font-weight:bold;">
                <asp:Label ID="BackToTopLabel" runat="server" Text="<%$ Resources:Resource, Global_BackToTop %>" CssClass="reg_text red_inline_text"></asp:Label>
        </a>
        <asp:Button ID="AdminCloseThreadButton" runat="server" Text="<%$ Resources:Resource, ThreadDetails_AdminCloseThreadButton %>" 
                    Visible = "false" onclick="AdminCloseThreadButton_Click"  />
                
         </div> 
         </div>      
    </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>